/* SerialPort.h
 *
 *  Author: Bematech S.A.
 */

#ifndef __BILBAO_UTIL_SERIAL_CLASS_H__
#define __BILBAO_UTIL_SERIAL_CLASS_H__

#include "bilbao/types.h"

namespace bilbao
{
	namespace util
	{
		class SerialPort
		{
		public:
			/**
			 * Construtor Padrão
			 */
			SerialPort(void);

			/**
			 *
			 */
			SerialPort( const char* port );

			/**
			 *
			 */
			SerialPort( const char* port, int baudrate, int parity, int stopbit, int bits_dados );

			/**
			 *
			 */
			void configure( int baudrate, int parity, int stopbit, int bits_dados );

			/**
			 *
			 */
			int send( const char );

			/**
			 *
			 */
			int send( const char*, int );

			/**
			 *
			 */
			int receive( char* );

			/**
			 *
			 */
			int receive( char**, int );

			/**
			 *
			 */
			void finalize(void);

			/**
			 * Destrutor
			 */
			virtual ~SerialPort(void);

		private:

			/**
			 *
			 */
			int _fd;

			/**
			 *
			 */
			std::string _port;

			/**
			 *
			 */
			int _baudrate;

			/**
			 *
			 */
			int _parity;

			/**
			 *
			 */
			int _stopbit;

			/**
			 *
			 */
			int _bits_data;
		};
	} //namespace utils
} //namespace bilbao

#endif //__BILBAO_UTILS_SERIAL_CLASS_H__
